package javase.socket.net;

import java.util.Date;
import java.util.Properties;

import javax.mail.Message;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

public class JavaMail {

	Properties props = new Properties();
	String smtp;
	String from = "yumeifly@sohu.com";
	String to = "iewin@citiz.net";
	Session session;
	Message message;

	public JavaMail() {
		smtp = "smtp.sohu.com";
		props.put("mail.transport.protocol", "smtp");
		props.put("mail.smtp.host", smtp);
		props.put("mail.smtp.port", "25");

		try {
			session = Session.getInstance(props);
			message = new MimeMessage(session);
			message.setFrom(new InternetAddress(from));
			message.setRecipient(Message.RecipientType.TO, new InternetAddress(to));
			message.setSentDate(new Date());
			message.setSubject("Hi");
			message.setText("This is my first test mail");
			Transport.send(message);
		} catch (Exception err) {
			System.out.println(err.toString());
		}

	}

	public static void main(String[] args) {
		JavaMail sm = new JavaMail();
	}

}
